package org.example.juc.atomic;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;

/**
 * @author songyafei
 */
public class LangAdderTest {

    static LongAdder longAdder = new LongAdder();

    public static void main(String[] args) {
        Long start =System.currentTimeMillis();
        for (int i = 0; i < 500000; i++) {
            new Thread(() -> {
                isum();
            }).start();

        }

        Long end =System.currentTimeMillis();
        System.out.println("耗时："+(start-end));
    }

    static void isum() {

        longAdder.increment();
        System.out.println(longAdder.sum());
    }
}
